package com.clstu.collection;

import java.util.ArrayList;
import java.util.List;

public class CollectionMethod {
    public static void main(String[] args) {
        List list=new ArrayList();//向上转型，编译类型是List（接口），运行类型是ArrayList
        list.add("jack");//动态绑定机制
        list.add(10);
        list.add(true);
        System.out.println(list);
        list.remove(true);//删除指定元素，返回boolea
        list.remove(1);//删除指定下标的元素
        System.out.println(list);
        System.out.println(list.contains("jack~"));
        System.out.println(list.isEmpty());
        list.clear();
        System.out.println(list);
        ArrayList list2= new ArrayList();
        list2.add("chen");
        list2.add("long");
        list.addAll(list2);

        System.out.println(list);
        System.out.println(list.containsAll(list2));
        list.removeAll(list2);
        System.out.println(list);
    }
}
